using System.Text;
public class PlayerData : BaseMsg
{
    public string name;
    public int atk;
    public int lev;

    public void Print()
    {
        Console.WriteLine("name:{0} atk:{1} lev:{2}", name, atk, lev);
    }

    public override int GetBytesSize()
    {
        return 4 + 4 + 4 + Encoding.UTF8.GetBytes(name).Length;
    }

    public override int Reading(byte[] bytes, int beginIndex = 0)
    {
        int index = beginIndex;
        name = ReadString(bytes, ref index);
        atk = ReadInt(bytes, ref index);
        lev = ReadInt(bytes, ref index);
        return index - beginIndex;
    }

    public override byte[] Writing()
    {
        int index = 0;
        byte[] bytes = new byte[this.GetBytesSize()];
        WriteString(bytes, name, ref index);
        WriteInt(bytes, atk, ref index);
        WriteInt(bytes, lev, ref index);
        return bytes;
    }
}